#!/usr/bin/env python
# encoding:utf-8
'''
测试with普通使用方式
'''
# 一般的方式打开文件，收到关闭close文件
def test_nomal_func():
    # 必须指定编码字符集
    f = open("testRefrence.html", "r", encoding="utf-8")
    try:
        while True:
            line = f.readline()
            if not line:
                break
            print(line)
    except:
        pass
    finally:
        f.close()
# 类似java try-with-resource自动关闭close文件
def test_spec_func():
    with open("testRefrence.html", "r", encoding="utf-8") as f:
            while True:
                line = f.readline()
                if not line:
                    break
                print(line)

if __name__ == '__main__':
    test_nomal_func()